<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>档案管理 - 修改</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script src="libs/handlebars.min.js"></script>
<script src="libs/js.cookie-2.1.0.min.js"></script>
<script src="libs/getQueryString.js"></script>
<script src="libs/md5.min.js"></script>
<script src="libs/jquery.backstretch.min.js"></script>
<link href="libs/dropzone.css" rel="stylesheet" />
<script src="libs/dropzone.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="col-md-12 page-header">
				<h2 class="text-center">修改档案信息</h2>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-6">

				<ul class="nav nav-pills pull-right">
					<li><a href="#">用戶：<span id="text13"></span></a></li>
					<li><a href="index.html">首页</a></li>
					<li><a href="add.html">添加</a></li>
					<li class="active"><a href="#">修改</a></li>
					<li><a href="count.html">统计</a></li>
					<li><a href="query.html">查询</a></li>
				</ul>

			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<hr />
			</div>
		</div>
	</div>
	<div class="container">
		<!-- Nav tabs -->
		<div class="col-md-12 col-md-offset-2">

			<ul class="nav nav-tabs" role="tablist">
				<li role="presentation" class="active"><a href="#home"
					aria-controls="home" role="tab" data-toggle="tab">档案信息</a></li>
				<li role="presentation"><a href="#profile"
					aria-controls="profile" role="tab" data-toggle="tab">档案图片</a></li>
				<li role="presentation"><a href="#messages"
					aria-controls="messages" role="tab" data-toggle="tab">上传文件
				
					</a></li>
			</ul>
		</div>
		<div class="col-md-12 col-md-offset-1">
			<!-- Tab panes -->
			<div class="tab-content">
				<div role="tabpanel" class="tab-pane active" id="home">
					<div class="panel-body" id="list1">
						<div class="container">
							<div class="row">
								<div class="col-md-12">
									<div class="col-md-2 ">

										<div class="form-group">
											<label for="id" >ID</label> <input type="text"
												class="form-control" id="id" readonly="readonly"  />
										</div>
                                       </div>
	                                <div class="col-md-2 col-md-offset-1">
										<div class="form-group">
											<label for="archive_id">档案号</label> <input type="text"
												class="form-control" id="archive_id" readonly="readonly" />
										</div>
									</div>
									<div class="col-md-2 col-md-offset-1">
										<div class="form-group">
											<label for="identity">身份证号码</label> <input type="text"
												class="form-control" id="identity" readonly="readonly"  />
										</div>
									</div>
									<div class="col-md-2 col-md-offset-1">
										<div class="form-group">
											<label for="name">姓名</label> <input type="text"
												class="form-control" id="name" />
										</div>
									</div>
									<div class="col-md-2 ">
										<div class="form-group">
											<label for="gender">性别</label> <input type="text"
												class="form-control" id="gender" />
										</div>
									</div>
									<div class="col-md-2 col-md-offset-1">
										<div class="form-group">
											<label for="birthday">出生日期</label> <input type="date"
												class="form-control" id="birthday" />
										</div>
									</div>
									<div class="col-md-2 col-md-offset-1">
										<div class="form-group">
											<label for="date_retire1">预退休日期</label> <input type="date"
												class="form-control" id="date_retire1" />
										</div>
									</div>
									<div class="col-md-2 col-md-offset-1">
										<div class="form-group">
											<label for="date_retire2">实际退休日期</label> <input type="date"
												class="form-control" id="date_retire2" />
	
										</div>
									</div>
									<div class="col-md-2 ">
										<div class="form-group">
											<label for="sp">特殊工种</label> <input type="text"
												class="form-control" id="sp" />
										</div>
									</div>
									<div class="col-md-2 col-md-offset-1">
										<div class="form-group">
											<label for="fc">女管理岗位</label> <input type="text"
												class="form-control" id="fc" />
										</div>
									</div>
									<div class="col-md-2 col-md-offset-1">
										<div class="form-group">
											<label for="title">职称</label> <input type="text"
												class="form-control" id="title" />
										</div>
									</div>
									<div class="col-md-2 col-md-offset-1">
										<div class="form-group">
											<label for="seniority">工龄</label> <input type="text"
												class="form-control" id="seniority" />
										</div>
									</div>
									<div class="col-md-5 col-md-offset-3">
										<button id="update" class="btn btn-primary btn-block">提交</button>
									</div>
								</div>
							</div>
						</div>
					</div>

				</div>
				<div role="tabpanel" class="tab-pane" id="profile">
					<div class="panel-body" id="list2"></div>
				</div>
				<div role="tabpanel" class="tab-pane" id="messages">
					<form id="dropzone" action="" class="dropzone" method="post"></form>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		$(function() {
			var id = getQueryString('id');
			$('#form').attr('action', id + '/upload.action');
			$('#myTabs a').click(function(e) {
				e.preventDefault()
				$(this).tab('show')
			})
			$.backstretch("photo/index.jpg");
			var id = getQueryString('id');
			var url = 'queryOneById.action?id=' + id;
			var url2 = 'update.action?id=' + id;
			console.log(url)
			$.getJSON(url, function(res) {
				$('#text1').text(res[0].id);
				console.log(res);
				$('#id').val(res[0].id);
				$('#archive_id').val(res[0].archive_id);
				$('#identity').val(res[0].identity);
				$('#name').val(res[0].name);
				$('#gender').val(res[0].gender);
				$('#birthday').val(res[0].birthday);
				$('#date_retire1').val(res[0].date_retire1);
				$('#date_retire2').val(res[0].date_retire2);
				$('#sp').val(res[0].sp);
				$('#fc').val(res[0].fc);
				$('#title').val(res[0].title);
				$('#seniority').val(res[0].seniority);
			});
			$('#update').click(function() {
				$.post(url2, {
					archive_id : $('#archive_id').val(),
					identity : $('#identity').val(),
					name : $('#name').val(),
					gender : $('#gender').val(),
					birthday : $('#birthday').val(),
					date_retire1 : $('#date_retire1').val(),
					date_retire2 : $('#date_retire2').val(),
					sp : $('#sp').val(),
					fc : $('#fc').val(),
					title : $('#title').val(),
					seniority : $('#seniority').val()
				}, function(res, status) {
					if ('OK' == res) {
						alert('修改成功');
						window.location.href = 'index.html';
					}
				});
			});

			$.getJSON('querynickname.action', function(res) {
				console.log(res);
				$('#text13').text(res[0].nickname);
			});
			$.getJSON('queryPhoto.action?id=' + id, function(res) {
				console.log(res);
				var data ={
					'item':res
				};
				var t = Handlebars.compile($('#template').html());
				$('#list2').html(t(data));
			});
			$('#delFile').click(function() {
				$.post('delFile.action', {
					id : id
				}, function(res, status) {
					if ('OK' == res) {
						alert('删除成功');
						//window.location.href = 'index.html';
					}
				})
			});
		});
	</script>
	<script id="template" type="text/x-handlebars-template">
    {{#each item}}
 	 <div class="col-md-4" >
   	  <div class="panel-body">
       <dl>
		<center> 
		   <p>
			<a href="delphoto.html?id={{id}}">
			 <img src="upload/{{archive_id}}/{{name}}" width="200" height="200" />
			</a>
		   </p>
		</center>
	   </dl>  
      </div>
   	 </div>
 	{{/each}}
	</script>
	<script type="text/javascript">
	  var id = getQueryString('id');
  			Dropzone.options.dropzone = {
  			  url: id + '/upload.action',
    		  clickable: true,
              acceptedFiles: '.jpg',
   			  dictDefaultMessage: '拖放图片文件到此位置',
    		  dictInvalidFileType: '错误的文件类型',
    		  dictFileTooBig: '文件过大',
    		  dictResponseError: '与服务器连接失败',
    		  dictCancelUpload: '已取消',
              dictCanceluploadConfirmation: '确认取消上传'
  			}
  </script>
	
</body>
</html>
